<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryData($event)"
  (onReset)="resetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-2">
  <div class="opera-wrap">
    <button
      nz-button
      nzType="primary"
      class="m-r-10"
      [nzLoading]="exportLoading"
      (click)="exportTableData()"
    >
      <i nz-icon nzType="download" nzTheme="outline"></i>导出
    </button>
  </div>
  
  <div class="pagination-wrap-position p-t-15">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" nzWidth="100px" nzLeft>ID</th>
          <th nzAlign="center" nzWidth="180px">关联订单号</th>
          <th nzAlign="center" nzWidth="120px">订单状态</th>
          <th nzAlign="center" nzWidth="120px">活动名称</th>
          <th nzAlign="center" nzWidth="120px">奖品类型</th>
          <th nzAlign="center" nzWidth="120px">奖品名称</th>
          <th nzAlign="center" nzWidth="170px">中奖时间</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- ID -->
          <td nzAlign="center" nzLeft>{{ data.id }}</td>
          <!-- 关联订单号 -->
          <td nzAlign="center">
            <ng-container *ngIf="data.orderNum; else elseDhTemplate">
              <a
                style="color: #409EFF;"
                target="_blank"
                routerLink="/aisi-recyc/loveOrderDetails"
                [queryParams]="{id: data.orderId}"
              >{{ data.orderNum ||'-' }}</a>
            </ng-container>
            <ng-template #elseDhTemplate>-</ng-template>
          </td>
          <!-- 订单状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.orderStatus | orderState: 'color'}">
              {{ data.orderStatus | orderState: 'text' }}
            </span>
          </td>
          <!-- 活动名称 -->
          <td nzAlign="center">{{ data.activityName || '-' }}</td>
          <!-- 奖品类型 -->
          <td nzAlign="center">{{ data.prizeType | lovePrizeType: 'label' }}</td>
          <!-- 奖品名称 -->
          <td nzAlign="center">{{ data.prizeName || '-' }}</td>
          <!-- 中奖时间 -->
          <td nzAlign="center">{{ data.createTime || '-' }}</td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>
